import numpy as np
import matplotlib.pyplot as plt


class Drawer(object):
    def __init__(self) -> None:
        self.count = 0
        self.data_set = []
        pass

    # 每隔一定的数量记录一次loss
    def record(self, x):
        if self.count % 1 == 0:
            self.data_set.append(x)
        self.count += 1

    # 绘制散点图
    def plot(self):
        x = np.arange(len(self.data_set))
        plt.scatter(x, self.data_set)
        plt.title("handwriting digits classification")
        plt.xlabel('num')
        plt.ylabel('loss')
        plt.legend('loss')
        plt.show()
